
define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Sales, $ionicSlideBoxDelegate,GoPage) {
		
		//一级导航--切换
		$scope.selectIndex = 0;
		$scope.slideChanged = function(index) {
			$scope.selectIndex = index;
		};
		$scope.activeSlide = function(index) {
			$scope.selectIndex = index;
			$ionicSlideBoxDelegate.$getByHandle('main-handle').slide(index);
		};
		
		//二级导航--我发起
		$scope.selectIndex_small = 0;
		$scope.slideChanged_small = function(index) {
			$scope.selectIndex_small = index;
		};
		$scope.activeSlide_small = function(index) {
			$scope.selectIndex_small = index;
			$ionicSlideBoxDelegate.$getByHandle('small-handle').slide(index);
		};
		//二级导航--制造商发起
		$scope.selectIndex_make = 0;
		$scope.slideChanged_make = function(index) {
			$scope.selectIndex_make = index;
		};
		$scope.activeSlide_make = function(index) {
			$scope.selectIndex_make = index;
			$ionicSlideBoxDelegate.$getByHandle('make-handle').slide(index);
		};
		//二级导航--品牌运营商发起
		$scope.selectIndex_brand = 0;
		$scope.slideChanged_brand = function(index) {
			$scope.selectIndex_brand = index;
		};
		$scope.activeSlide_brand = function(index) {
			$scope.selectIndex_brand = index;
			$ionicSlideBoxDelegate.$getByHandle('brand-handle').slide(index);
		};
		
		//数据获取
		Sales.get_detail(function(data) {
			$scope.detail = data;
		});
		
		//编辑图片--制造商发起、品牌运营商发起
		$scope.onshow_promotion = function(id){
			GoPage.go_states("promotion",{id:id});
		}
		//编辑图片--我发起
		$scope.onshow_d_add_agent = function(){
			GoPage.go_states("d_add_agent");
		}
		//促销统计--制造商发起
		$scope.onshow_promotionaddup = function(id){
			GoPage.go_states("promotionaddup",{id:id});
		}
		//促销统计---品牌运营商发起
		$scope.onshow_promotionaddup_agent = function(id){
			GoPage.go_states("promotionaddup_agent",{id:id});
		}
		//促销统计---我发起
		$scope.onshow_promotionaddup_add_agent = function(id){
			GoPage.go_states("promotionaddup_add_agent",{id:id});
		}
		Sales.get_mfacturer(1,1,function(data){
			$scope.m_doing = data;
		});
		Sales.get_mfacturer(1,2,function(data){
			$scope.m_pending = data;
		});
		Sales.get_mfacturer(1,3,function(data){
			$scope.m_ended = data;
		});
		Sales.get_agential(1,1,function(data){
			$scope.a_doing = data;
		});
		Sales.get_agential(1,2,function(data){
			$scope.a_pending = data;
		});
		Sales.get_agential(1,3,function(data){
			$scope.a_ended = data;
		});
        Sales.get_mine(1,1,function(data){
        	$scope.mine_doing = data;
        });
         Sales.get_mine(1,2,function(data){
        	$scope.mine_pending = data;
        });
          Sales.get_mine(1,3,function(data){
        	$scope.mine_ended = data;
        });

	}

	controller.$inject = ['$scope', 'Sales', '$ionicSlideBoxDelegate','GoPage'];

	return app.registerController("salesctrl",controller);
});